function togglediv(divid){

    //    $('.hidediv').addClass('showdiv');
    //    $('#deliveryaddr').removeClass('showdiv');
    if (document.getElementById(divid).style.display == "none" || document.getElementById(divid).style.display == "") {
        document.getElementById(divid).style.display = "block";
    } else if (document.getElementById(divid).style.display == "block") {
        document.getElementById(divid).style.display = "none";
    } else {
        document.getElementById(divid).style.display = "none";
    }
}

function validateRegForm(actionpath,formname){
    
    var registrationForm = document.forms[formname];    
    var errmsgpi = document.getElementById('errspanidpi');
    var errdivpi = document.getElementById('errdividpi');
    var errmsgli = document.getElementById('errspanidli');
    var errdivli = document.getElementById('errdividli');
    var errmsgbai = document.getElementById('errspanidbai');
    var errdivbai = document.getElementById('errdividbai');
    var errmsgdai = document.getElementById('errspaniddai');
    var errdivdai = document.getElementById('errdividdai');
    
    var min =6;
    var max = 15;    
    
    var nowgetDay;
    var nowgetMonth;
    var today = new Date();
    var todayDate = today.getDate();
    if (todayDate < 10)    {
        nowgetDay ="0"+ today.getDate();
    } else    {
        nowgetDay = today.getDate();
    }
    if(today.getMonth()<10){
        nowgetMonth = "0"+today.getMonth();
    }
    else    {
        nowgetMonth = today.getMonth();
    }

    var now = nowgetDay +"/"+ nowgetMonth +"/"+ today.getFullYear();
    var dobDate = registrationForm.dateOfBirth.value;
    var dobday = parseInt(dobDate.substring(0, 2), 10);
    var dobmonth = parseInt(dobDate.substring(3, 5), 10);
    var dobyear = parseInt(dobDate.substring(6, 10), 10);
    var nowday= parseInt(now.substring(0, 2), 10);
    var nowmonth = parseInt(now.substring(3, 5), 10);
    var nowyear = parseInt(now.substring(6, 10), 10);
    var nowdate=new Date(nowyear,nowmonth,nowday);
    var formateddobdate= new Date(dobyear,dobmonth-1,dobday);

    var CheckboxHandler = new Object();
    CheckboxHandler.isChecked = function (checkboxObj) {
        return(checkboxObj.checked == true);
    };    
    var MatchAlpha = new Object();
    MatchAlpha.isMatched= function(data){
        var alphaExp = /^[a-zA-Z]+$/;
        if(data.match(alphaExp)){
            return true;
        }else{
            return false;
        }
    };
    var MatchNumeric = new Object();    
    MatchNumeric.isMatched = function(data){
        var numericExp = /^[0-9]+$/;
        if(data.match(numericExp)){
            return true
        }else{
            return false;
        }
    };
    var MatchEmail = new Object();
    MatchEmail.isMatched = function(data){
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(data.match(emailExp)){
            return true
        }else{
            return false;
        }
    };
    var CheckSplChar = new Object();
    CheckSplChar.isMatched = function(data){
        var iChars =  "!@#$%^&*()+=-[]\\\';,/{}|\":<>?~";
        var i;
        for (i = 0; i < data.length; i++){
            if (iChars.indexOf(data.charAt(i)) != -1){
                return false;
            }
        }
        return true;
    };

    var AttributeAddRemPI = new Object();
    AttributeAddRemPI.isDone= function(msg){
        errdivpi.setAttribute('class', 'errdivclass');
        errmsgpi.setAttribute('class', 'errspanclass');
        errmsgpi.innerHTML = msg;
        errdivpi.appendChild(errmsgpi);
        errdivli.removeAttribute('class');
        errmsgli.removeAttribute('class');
        errmsgli.innerHTML="";
        errdivbai.removeAttribute('class');
        errmsgbai.removeAttribute('class');
        errmsgbai.innerHTML="";
        errdivdai.removeAttribute('class');
        errmsgdai.removeAttribute('class');
        errmsgdai.innerHTML="";        
    };
    var AttributeAddRemLI = new Object();
    AttributeAddRemLI.isDone= function(msg){
        errdivli.setAttribute('class', 'errdivclass');
        errmsgli.setAttribute('class', 'errspanclass');
        errmsgli.innerHTML = msg;
        errdivli.appendChild(errmsgli);
        errdivpi.removeAttribute('class');
        errmsgpi.removeAttribute('class');
        errmsgpi.innerHTML="";
        errdivbai.removeAttribute('class');
        errmsgbai.removeAttribute('class');
        errmsgbai.innerHTML="";
        errdivdai.removeAttribute('class');
        errmsgdai.removeAttribute('class');
        errmsgdai.innerHTML="";

    };
    var AttributeAddRemBAI = new Object();
    AttributeAddRemBAI.isDone= function(msg){
        errdivbai.setAttribute('class', 'errdivclass');
        errmsgbai.setAttribute('class', 'errspanclass');
        errmsgbai.innerHTML = msg;
        errdivbai.appendChild(errmsgbai);
        errdivli.removeAttribute('class');
        errmsgli.removeAttribute('class');
        errmsgli.innerHTML="";
        errdivpi.removeAttribute('class');
        errmsgpi.removeAttribute('class');
        errmsgpi.innerHTML="";
        errdivdai.removeAttribute('class');
        errmsgdai.removeAttribute('class');
        errmsgdai.innerHTML="";

    };
    var AttributeAddRemDAI = new Object();
    AttributeAddRemDAI.isDone= function(msg){
        errdivdai.setAttribute('class', 'errdivclass');
        errmsgdai.setAttribute('class', 'errspanclass');
        errmsgdai.innerHTML = msg;
        errdivdai.appendChild(errmsgdai);
        errdivli.removeAttribute('class');
        errmsgli.removeAttribute('class');
        errmsgli.innerHTML="";
        errdivbai.removeAttribute('class');
        errmsgbai.removeAttribute('class');
        errmsgbai.innerHTML="";
        errdivpi.removeAttribute('class');
        errmsgpi.removeAttribute('class');
        errmsgpi.innerHTML="";
        
    };

    if(registrationForm.prefix.selectedIndex == 0 ||registrationForm.firstName.value == ""||registrationForm.lastName.value == ""||registrationForm.emailId.value == ""||registrationForm.mobileNo.value == ""||registrationForm.dateOfBirth.value == "" ){
        AttributeAddRemPI.isDone("All Personal Information details are required");
        return false;
    } else if (MatchAlpha.isMatched(registrationForm.firstName.value) == false){
        AttributeAddRemPI.isDone("Please use letters only (a-z or A-Z) in First Name.");
        registrationForm.firstName.focus();
        return false;
    }else if(registrationForm.middleName.value != "" && MatchAlpha.isMatched(registrationForm.middleName.value) == false ){
        AttributeAddRemPI.isDone("Please use letters only (a-z or A-Z) in Middle Name.");
        registrationForm.middleName.focus();
        return false;
    }else if (MatchAlpha.isMatched(registrationForm.lastName.value) == false){
        AttributeAddRemPI.isDone("Please use letters only (a-z or A-Z) in Last Name.");
        registrationForm.lastName.focus();
        return false;
    } else if(registrationForm.profession.value != ""){
        if (MatchAlpha.isMatched(registrationForm.profession.value) == false){
            AttributeAddRemPI.isDone( "Please use letters only (a-z or A-Z) in Profession.");
            registrationForm.profession.focus();
            return false;
        }
    } else if (MatchEmail.isMatched(registrationForm.emailId.value) == false){
        AttributeAddRemPI.isDone("Please enter a valid email address. For example johndoe@domain.com.");
        registrationForm.emailId.focus();
        return false;
    }else if (MatchNumeric.isMatched(registrationForm.mobileNo.value) == false){
        AttributeAddRemPI.isDone("Please use numbers only (0-9) in Mobile No.");
        registrationForm.mobileNo.focus();
        return false;
    } else if (registrationForm.mobileNo.value.length < 10 || registrationForm.mobileNo.value.length > 10){
        AttributeAddRemPI.isDone("Mobile No. should be of 10 digits");
        registrationForm.mobileNo.focus();
        return false;
    }
    if(registrationForm.securityQuestion.selectedIndex==0 ||registrationForm.answer.value==""||registrationForm.userName.value==""||registrationForm.password.value=="" ||registrationForm.confirmPassword.value==""){           
        AttributeAddRemLI.isDone( "All Login Information details are required");
        return false;
    } else if (CheckSplChar.isMatched(registrationForm.userName.value)== false){
        AttributeAddRemLI.isDone( "Special characters not allowed in Username.");
        registrationForm.userName.focus();
        return false;
    } else if(registrationForm.userName.value.length <= min || registrationForm.userName.value.length >= max) {
        AttributeAddRemLI.isDone("Please enter username between 6 to 15 characters only.");
        registrationForm.userName.focus();
        return false;
    } else if (registrationForm.password.value.length <= min){
        AttributeAddRemLI.isDone("Password should be of more than 6 characters. Leading or trailing spaces will be ignored.");
        registrationForm.password.focus();
        return false;
    }else if (registrationForm.confirmPassword.value != registrationForm.password.value){
        AttributeAddRemLI.isDone("Please make sure your passwords match.");
        registrationForm.confirmPassword.focus();
        return false;
    }
    if(registrationForm.billingHouse.value=="" || registrationForm.billingStreet.value=="" || registrationForm.billingCity.value=="" || registrationForm.billingPinCode.value=="" || registrationForm.billingState.selectedIndex==0 ||registrationForm.billingContact.value=="" ){
        AttributeAddRemBAI.isDone("All Billing Address Information details are required");
        return false;
    }else if (MatchAlpha.isMatched(registrationForm.billingCity.value) == false){
        AttributeAddRemBAI.isDone("Please use letters only (a-z or A-Z) in Billing City.");
        registrationForm.billingCity.focus();
        return false;
    }else if (MatchNumeric.isMatched(registrationForm.billingPinCode.value) == false){
        AttributeAddRemBAI.isDone( "Please use numbers only (0-9) in Billing Pin Code");
        registrationForm.billingPinCode.focus();
        return false;
    }else if (MatchNumeric.isMatched(registrationForm.billingContact.value) == false){
        AttributeAddRemBAI.isDone( "Please use numbers only (0-9) in Billing Contact No");
        registrationForm.billingContact.focus();
        return false;
    }
    if(CheckboxHandler.isChecked(registrationForm.sameBillingAddr)==false){
        if(registrationForm.deliveryHouse.value=="" || registrationForm.deliveryStreet.value=="" || registrationForm.deliveryCity.value=="" || registrationForm.deliveryPinCode.value=="" || registrationForm.deliveryState.selectedIndex==0 || registrationForm.deliveryContact.value==""){
            AttributeAddRemDAI.isDone( "All Delivery Address Information details are required");
            return false;
        }else if (MatchAlpha.isMatched(registrationForm.deliveryCity.value) == false){  
            AttributeAddRemDAI.isDone("Please use letters only (a-z or A-Z) in delivery City.");
            registrationForm.deliveryCity.focus();
            return false;
        }else if (MatchNumeric.isMatched(registrationForm.deliveryPinCode.value) == false){           
            AttributeAddRemDAI.isDone("Please use numbers only (0-9) in delivery Pin Code");
            registrationForm.billingPinCode.focus();
            return false;
        }else if (MatchNumeric.isMatched(registrationForm.deliveryContact.value) == false){  
            AttributeAddRemDAI.isDone("Please use numbers only (0-9) in delivery Contact No");
            registrationForm.deliveryContact.focus();
            return false;
        }
    }
    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateLogin(actionpath,formname){
    var loginForm = document.forms[formname];
    var errmsglogin = document.getElementById('errspanidlogin');
    var errdivlogin = document.getElementById('errdividlogin');
    var AttributeAddRemLogin = new Object();

    AttributeAddRemLogin.isDone=function(msg){
        errdivlogin.setAttribute('class', 'errdivclass');
        errmsglogin.setAttribute('class', 'errspanclass');
        errmsglogin.innerHTML = msg;
        errdivlogin.appendChild(errmsglogin);
    };
        
    if((loginForm.userName.value=="" || loginForm.password.value=="" )){
        AttributeAddRemLogin.isDone("Username & Password are required");
        loginForm.userName.focus();
        return false;
    }else if (loginForm.userName.length <= 6 && loginForm.userName.value.length >= 15){
        AttributeAddRemLogin.isDone("Please enter username between 6 to 15 characters only.");
        loginForm.userName.focus();
        return false;
    }
    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateForgotPassword(actionpath,formname){
    var forgotPasswordForm = document.forms[formname];

    var errmsgfp = document.getElementById('errspanidfp');
    var errdivfp = document.getElementById('errdividfp');
    var AttributeAddRemFP = new Object();

    AttributeAddRemFP.isDone=function(msg){
        errdivfp.setAttribute('class', 'errdivclass');
        errmsgfp.setAttribute('class', 'errspanclass');
        errmsgfp.innerHTML = msg;
        errdivfp.appendChild(errmsgfp);
    };
    var MatchEmail = new Object();
    MatchEmail.isMatched = function(data){
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(data.match(emailExp)){
            return true
        }else{
            return false;
        }
    };
    if(forgotPasswordForm.emailId.value==0 || forgotPasswordForm.securityQuestion.selectedIndex==0 ||forgotPasswordForm.answer.value=="" ){
        AttributeAddRemFP.isDone("All the fields are required of Forgot Password");
        forgotPasswordForm.emailId.focus();
        return false;
    }else if (MatchEmail.isMatched(forgotPasswordForm.emailId.value)== false){
        AttributeAddRemFP.isDone("Please enter a valid email address. For example johndoe@domain.com.");
        forgotPasswordForm.emailId.focus();
        return false;
    }
    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateEditAccount(actionpath,formname){
    
    var editAccountForm = document.forms[formname];
    var CheckboxHandler = new Object();
    CheckboxHandler.isChecked = function (checkboxObj) {
        return(checkboxObj.checked == true);
    };
    var MatchAlpha = new Object();
    MatchAlpha.isMatched= function(data){
        var alphaExp = /^[a-zA-Z]+$/;
        if(data.match(alphaExp)){
            return true;
        }else{
            return false;
        }
    };
    var MatchNumeric = new Object();

    MatchNumeric.isMatched = function(data){
        var numericExp = /^[0-9]+$/;
        if(data.match(numericExp)){
            return true
        }else{
            return false;
        }
    };
    var MatchEmail = new Object();
    MatchEmail.isMatched = function(data){
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(data.match(emailExp)){
            return true
        }else{
            return false;
        }
    };

    var errdivea = document.getElementById('errdividea');
    var errmsgea= document.getElementById('errspanidea');
    if(editAccountForm.titleId.selectedIndex == 0 ||editAccountForm.firstName.value == ""||editAccountForm.lastName.value == ""||editAccountForm.emailId.value == ""||editAccountForm.mobileNo.value == ""||editAccountForm.dateOfBirth.value == "" ){
        errdivea.setAttribute('class', 'errdivclass');
        errmsgea.setAttribute('class', 'errspanclass');
        errmsgea.innerHTML = "All Personal Information details are required";
        errdivea.appendChild(errmsgea);
        return false;
    } else if (MatchAlpha.isMatched(editAccountForm.firstName.value) == false){
        errdivea.setAttribute('class', 'errdivclass');
        errmsgea.setAttribute('class', 'errspanclass');
        errmsgea.innerHTML = "Please use letters only (a-z or A-Z) in First Name.";
        errdivea.appendChild(errmsgea);
        editAccountForm.firstName.focus();
        return false;
    }else if(editAccountForm.middleName.value != ""){
        if (MatchAlpha.isMatched(editAccountForm.middleName.value) == false){
            errdivea.setAttribute('class', 'errdivclass');
            errmsgea.setAttribute('class', 'errspanclass');
            errmsgea.innerHTML = "Please use letters only (a-z or A-Z) in Middle Name.";
            errdivea.appendChild(errmsgea);
            editAccountForm.middleName.focus();
            return false;
        }
    }else if (MatchAlpha.isMatched(editAccountForm.lastName.value) == false){
        errdivea.setAttribute('class', 'errdivclass');
        errmsgea.setAttribute('class', 'errspanclass');
        errmsgea.innerHTML = "Please use letters only (a-z or A-Z) in Last Name.";
        errdivea.appendChild(errmsgea);
        editAccountForm.lastName.focus();
        return false;
    } else if(editAccountForm.profession.value != ""){
        if (MatchAlpha.isMatched(editAccountForm.profession.value) == false){
            errdivea.setAttribute('class', 'errdivclass');
            errmsgea.setAttribute('class', 'errspanclass');
            errmsgea.innerHTML = "Please use letters only (a-z or A-Z) in Profession.";
            errdivea.appendChild(errmsgea);
            editAccountForm.profession.focus();
            return false;
        }
    } else if (MatchEmail.isMatched(editAccountForm.emailId.value) == false){
        errdivea.setAttribute('class', 'errdivclass');
        errmsgea.setAttribute('class', 'errspanclass');
        errmsgea.innerHTML = "Please enter a valid email address. For example johndoe@domain.com.";
        errdivea.appendChild(errmsgea);
        editAccountForm.emailId.focus();
        return false;
    }else if (MatchNumeric.isMatched(editAccountForm.mobileNo.value) == false){
        errdivea.setAttribute('class', 'errdivclass');
        errmsgea.setAttribute('class', 'errspanclass');
        errmsgea.innerHTML = "Please use numbers only (0-9) in Mobile No.";
        errdivea.appendChild(errmsgea);
        editAccountForm.mobileNo.focus();
        return false;
    } else if (editAccountForm.mobileNo.value.length < 10 || editAccountForm.mobileNo.value.length > 10){
        errdivea.setAttribute('class', 'errdivclass');
        errmsgea.setAttribute('class', 'errspanclass');
        errmsgea.innerHTML = "Mobile No. can't be greater than 10 digits";
        errdivea.appendChild(errmsgea);
        editAccountForm.mobileNo.focus();
        return false;
    }
    else if(CheckboxHandler.isChecked(editAccountForm.changePassword)==true){
        if(editAccountForm.currentPassword.value=="" || editAccountForm.newPassword.value=="" || editAccountForm.confirmNewPassword.value==""){
            errdivea.setAttribute('class', 'errdivclass');
            errmsgea.setAttribute('class', 'errspanclass');
            errmsgea.innerHTML = "All the details of Change Password are required";
            errdivea.appendChild(errmsgea);
            editAccountForm.currentPassword.focus();
            return false;
        }
    }
    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateEditAddress(actionpath,formname){
    
    var editAddressForm = document.forms[formname];
    var errmsged = document.getElementById('errspanided');
    var errdived = document.getElementById('errdivided');

    var MatchAlpha = new Object();
    MatchAlpha.isMatched= function(data){
        var alphaExp = /^[a-zA-Z]+$/;
        if(data.match(alphaExp)){
            return true;
        }else{
            return false;
        }
    };
    var MatchNumeric = new Object();
    MatchNumeric.isMatched = function(data){
        var numericExp = /^[0-9]+$/;
        if(data.match(numericExp)){
            return true
        }else{
            return false;
        }
    };

    var AttributeAddRemED = new Object();
    AttributeAddRemED.isDone= function(msg){
        errdived.setAttribute('class', 'errdivclass');
        errmsged.setAttribute('class', 'errspanclass');
        errmsged.innerHTML = msg;
        errdived.appendChild(errmsged);
    };
    
    if(editAddressForm.titleId.selectedIndex == 0 ||editAddressForm.addrFirstName.value == ""||editAddressForm.addrLastName.value == ""){
        AttributeAddRemED.isDone("All Address Information details are required");
        return false;
    } else if (MatchAlpha.isMatched(editAddressForm.addrFirstName.value) == false){
        AttributeAddRemED.isDone("Please use letters only (a-z or A-Z) in First Name.");
        editAddressForm.addrFirstName.focus();
        return false;
    }else if(editAddressForm.addrMiddleName.value != "" && MatchAlpha.isMatched(editAddressForm.addrMiddleName.value) == false ){
        AttributeAddRemED.isDone("Please use letters only (a-z or A-Z) in Middle Name.");
        editAddressForm.addrMiddleName.focus();
        return false;
    }else if (MatchAlpha.isMatched(editAddressForm.addrLastName.value) == false){
        AttributeAddRemED.isDone("Please use letters only (a-z or A-Z) in Last Name.");
        editAddressForm.addrLastName.focus();
        return false;
    }
    
    if(editAddressForm.house.value=="" || editAddressForm.street.value=="" || editAddressForm.city.value=="" || editAddressForm.pinCode.value=="" || editAddressForm.stateId.selectedIndex==0 ||editAddressForm.contact.value=="" ){
        AttributeAddRemED.isDone("All Address Information details are required");
        return false;
    }else if (MatchAlpha.isMatched(editAddressForm.city.value) == false){
        AttributeAddRemED.isDone("Please use letters only (a-z or A-Z) in City.");
        editAddressForm.city.focus();
        return false;
    }else if (MatchNumeric.isMatched(editAddressForm.pinCode.value) == false){
        AttributeAddRemED.isDone( "Please use numbers only (0-9) in Pin Code");
        editAddressForm.pinCode.focus();
        return false;
    }else if (MatchNumeric.isMatched(editAddressForm.contact.value) == false){
        AttributeAddRemED.isDone( "Please use numbers only (0-9) in Contact No");
        editAddressForm.contact.focus();
        return false;
    }
    
    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateProduct(actionpath,formname){
    
    var productForm = document.forms[formname];
        
    var errmsgproduct = document.getElementById('errspanidproduct');
    var errdivproduct = document.getElementById('errdividproduct');

    var CheckboxHandler = new Object();
    CheckboxHandler.isChecked = function (checkboxObj) {
        return(checkboxObj.checked == true);
    };
    var MatchNumeric = new Object();
    MatchNumeric.isMatched = function(data){
        var numericExp = /^[0-9]+$/;
        if(data.match(numericExp)){
            return true
        }else{
            return false;
        }
    };

    var AttributeAddRemProduct = new Object();
    AttributeAddRemProduct.isDone=function(msg){
        errdivproduct.setAttribute('class', 'errdivclass');
        errmsgproduct.setAttribute('class', 'errspanclass');
        errmsgproduct.innerHTML = msg;
        errdivproduct.appendChild(errmsgproduct);
    };
    
    if(productForm.productName.value=="" ||productForm.productTitle.value==""||productForm.productDescription.value==""||productForm.productPrice.value ==""|| productForm.productDiscount.value==""|| productForm.productQty.value=="" ||productForm.productBrandId.selectedIndex ==0 || productForm.productCategoryId.selectedIndex ==0|| productForm.productStatusId.selectedIndex==0){
        AttributeAddRemProduct.isDone("All the fields are required for Product Details");
        return false;
    }else if (MatchNumeric.isMatched(productForm.productPrice.value) == false){
        AttributeAddRemProduct.isDone("Please use numbers only (0-9) in Product Price.");
        productForm.productPrice.focus();
        return false;
    }else if(productForm.productPrice.value <= 0){
        AttributeAddRemProduct.isDone("Price should be greater than 0");
        productForm.productPrice.focus();
        return false;
    }else if (MatchNumeric.isMatched(productForm.productDiscount.value) == false){
        AttributeAddRemProduct.isDone("Please use numbers only (0-9) in Product Discount.");
        productForm.productDiscount.focus();
        return false;
    }else if(productForm.productDiscount.value <= 0){
        AttributeAddRemProduct.isDone("Discount should be greater than 0");
        productForm.productDiscount.focus();
        return false;
    }else if (MatchNumeric.isMatched(productForm.productQty.value) == false){
        AttributeAddRemProduct.isDone("Please use numbers only (0-9) in Product Discount.");
        productForm.productDiscount.focus();
        return false;
    }else if(productForm.productQty.value <= 0){
        AttributeAddRemProduct.isDone("Discount should be greater than 0");
        productForm.productDiscount.focus();
        return false;
    }else if(CheckboxHandler.isChecked(productForm.productTaxable)==true){
        if(productForm.productTaxValue.value==""){
            AttributeAddRemProduct.isDone("If Product is Taxable provide the Tax Value");
            return false;
        }else if (MatchNumeric.isMatched(productForm.productTaxValue.value) == false){
            AttributeAddRemProduct.isDone("Please use numbers only (0-9) in Tax Value.");
            productForm.productTaxValue.focus();
            return false;
        }else if(productForm.productTaxValue.value <= 0){
            AttributeAddRemProduct.isDone("Tax should be greater than 0");
            productForm.productTaxValue.focus();
            return false;
        }
    } else if(productForm.productSmallImage.value != "" || productForm.productSmallImage.value.length>0){
        if(/.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(productForm.productSmallImage.value.toLowerCase())== false){
            AttributeAddRemProduct.isDone("Please Upload GIF/PNG or JPG/JPEG Images Files Only.");
            return false;
        }   
    } else if(productForm.productLargeImage.value != "" || productForm.productLargeImage.value.length>0){
        if(/.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(productForm.productLargeImage.value.toLowerCase())==false){
            AttributeAddRemProduct.isDone("Please Upload GIF/PNG or JPG/JPEG Images Files Only.");
            return false;    
        }
    }

    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateCategory(actionpath,formname){
    
    var categoryForm = document.forms[formname];        

    var CheckboxHandler = new Object();
    CheckboxHandler.isChecked = function (checkboxObj) {
        return(checkboxObj.checked == true);
    };
    
    var errmsgcategory = document.getElementById('errspanidcategory');
    var errdivcategory = document.getElementById('errdividcategory');
    var AttributeAddRemCategory = new Object();
    AttributeAddRemCategory.isDone=function(msg){
        errdivcategory.setAttribute('class', 'errdivclass');
        errmsgcategory.setAttribute('class', 'errspanclass');
        errmsgcategory.innerHTML = msg;
        errdivcategory.appendChild(errmsgcategory);
    };           
    
    if(categoryForm.categoryName.value==""||categoryForm.categoryTitle.value==""||(CheckboxHandler.isChecked(categoryForm.mainCategory)==false && categoryForm.parentCategoryId.selectedIndex==0)||categoryForm.categoryStatusId.selectedIndex==0||categoryForm.categoryDesc.value==""){
        AttributeAddRemCategory.isDone("All the fields are required for Category Details");
        return false;
    }
    else if(categoryForm.categoryImage.value != "" || categoryForm.categoryImage.value.length>0){
        if(/.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(categoryForm.categoryImage.value.toLowerCase())==false){
            AttributeAddRemCategory.isDone("Please Upload GIF/PNG or JPG/JPEG Images Files Only.");
            return false;
        }
    }
    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateBrand(actionpath,formname){
    var brandForm = document.forms[formname];    

    var errmsgbrand = document.getElementById('errspanidbrand');
    var errdivbrand = document.getElementById('errdividbrand');
    var AttributeAddRemBrand = new Object();

    AttributeAddRemBrand.isDone=function(msg){
        errdivbrand.setAttribute('class', 'errdivclass');
        errmsgbrand.setAttribute('class', 'errspanclass');
        errmsgbrand.innerHTML = msg;
        errdivbrand.appendChild(errmsgbrand);
    };

    if(brandForm.brandName.value==""||brandForm.brandTitle.value==""||
        brandForm.brandStatusId.selectedIndex==0||brandForm.brandDesc.value==""){
        AttributeAddRemBrand.isDone("All the fields are required for Brand Details");
        return false;
    }else if(brandForm.brandLogo.value != "" || brandForm.brandLogo.value.length>0){
        if(/.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(brandForm.brandLogo.value.toLowerCase())==false){
            AttributeAddRemBrand.isDone("Please Upload GIF/PNG or JPG/JPEG Images Files Only.");
            return false;
        }
    }

    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function validateHomePageImage(actionpath,formname){
    var imageForm = document.forms[formname];

    var errmsgimage = document.getElementById('errspanidimage');
    var errdivimage = document.getElementById('errdividimage');
    var AttributeAddRemImage = new Object();

    AttributeAddRemImage.isDone=function(msg){
        errdivimage.setAttribute('class', 'errdivclass');
        errmsgimage.setAttribute('class', 'errspanclass');
        errmsgimage.innerHTML = msg;
        errdivimage.appendChild(errmsgimage);
    };
    if(imageForm.imageName.value==""||imageForm.imageDetail.value==""){
        AttributeAddRemImage.isDone("All the fields are required for Home Page Image");
        return false;
    }else if(imageForm.homePageImage.value != "" || imageForm.homePageImage.value.length>0){
        if(/.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(imageForm.homePageImage.value.toLowerCase())==false){
            AttributeAddRemImage.isDone("Please Upload GIF/PNG or JPG/JPEG Images Files Only.");
            return false;
        }
    }

    document.forms[formname].action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    document.forms[formname].submit();
    return true;
}

function searchBrand(actionpath,formname){
    var brandForm = document.forms[formname];
    
    brandForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    brandForm.submit();
    return true;
}

function searchCategory(actionpath,formname){
    var categoryForm = document.forms[formname];

    categoryForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    categoryForm.submit();
    return true;
}

function searchProduct(actionpath,formname){
    
    var productForm = document.forms[formname];

    productForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    productForm.submit();
    return true;
}

function searchUser(actionpath,formname){
    var userForm = document.forms[formname];

    userForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    userForm.submit();
    return true;
}

function deleteUserInfo(actionpath,formname){
    var userForm = document.forms[formname];

    userForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    userForm.submit();
    return true;
}
function deleteBrand(actionpath,formname){
    var brandForm = document.forms[formname];
    
    brandForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    brandForm.submit();
    return true;
}
function deleteProduct(actionpath,formname){
    var productForm = document.forms[formname];

    productForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    productForm.submit();
    return true;
}
function deleteCategory(actionpath,formname){
    var categoryForm = document.forms[formname];

    categoryForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    categoryForm.submit();
    return true;
}
function deleteImage(actionpath,formname){
    var ImageForm = document.forms[formname];

    ImageForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    ImageForm.submit();
    return true;
}

function subscribe(actionpath,formname){
    
    var newsletterForm = document.forms[formname];
    var errmsgnl = document.getElementById('errspanidnl');
    var errdivnl = document.getElementById('errdividnl');
    var AttributeAddRemNL = new Object();

    AttributeAddRemNL.isDone=function(msg){
        errdivnl.setAttribute('class', 'errdivclass');
        errmsgnl.setAttribute('class', 'errspanclass');
        errmsgnl.innerHTML = msg;
        errdivnl.appendChild(errmsgnl);
    };

    var MatchEmail = new Object();
    MatchEmail.isMatched = function(data){
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(data.match(emailExp)){
            return true
        }else{
            return false;
        }
    };
    
    if(newsletterForm.newsLetterEmail.value == ""){
        AttributeAddRemNL.isDone("Please enter your Email Id to Subscribe / Unsubscribe from Newsletter ");
        newsletterForm.newsLetterEmail.focus();
        return false;
    }else if (MatchEmail.isMatched(newsletterForm.newsLetterEmail.value) == false){
        AttributeAddRemNL.isDone("Please enter a valid email address. For example johndoe@domain.com.");
        newsletterForm.newsLetterEmail.focus();
        return false;
    }

    newsletterForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    newsletterForm.submit();
    return true;
}

function validateAddToCart(actionpath,formname){
    var addToCartForm = document.forms[formname];
    var errmsgatc = document.getElementById('errspanidatc');
    var errdivatc = document.getElementById('errdividatc');
    var AttributeAddRemATC = new Object();

    AttributeAddRemATC.isDone=function(msg){
        errdivatc.setAttribute('class', 'errdivclass');
        errmsgatc.setAttribute('class', 'errspanclass');
        errmsgatc.innerHTML = msg;
        errdivatc.appendChild(errmsgatc);
    };
    var MatchNumeric = new Object();
    MatchNumeric.isMatched = function(data){
        var numericExp = /^[0-9]+$/;
        if(data.match(numericExp)){
            return true
        }else{
            return false;
        }
    };

    if(addToCartForm.addToCartQty.value==""){
        AttributeAddRemATC.isDone("Please insert quantity value.");
        addToCartForm.addToCartQty.focus();
        return false;
    }else if (MatchNumeric.isMatched(addToCartForm.addToCartQty.value) == false){
        AttributeAddRemATC.isDone("Please use numbers only (0-9) in Quantity.");
        addToCartForm.addToCartQty.focus();
        return false;
    }else if(addToCartForm.addToCartQty.value < 0){
        AttributeAddRemATC.isDone("Quantity should be greater than 0");
        addToCartForm.addToCartQty.focus();
        return false;
    }
    addToCartForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    addToCartForm.submit();
    return true;
}

function advSearch(actionpath,formname){
    
    var advSearchForm = document.forms[formname];
    var errmsgas = document.getElementById('errspanidas');
    var errdivas = document.getElementById('errdividas');
    var AttributeAddRemAS = new Object();

    AttributeAddRemAS.isDone=function(msg){
        errdivas.setAttribute('class', 'errdivclass');
        errmsgas.setAttribute('class', 'errspanclass');
        errmsgas.innerHTML = msg;
        errdivas.appendChild(errmsgas);
    };
    var MatchNumeric = new Object();
    MatchNumeric.isMatched = function(data){
        var numericExp = /^[0-9]+$/;
        if(data.match(numericExp)){
            return true
        }else{
            return false;
        }
    };

    if(advSearchForm.searchCriteria.selectedIndex == 0 && advSearchForm.product.value ==""){
        AttributeAddRemAS.isDone("Please enter value in Keyword field.");
        advSearchForm.product.focus();
        return false;
    }else if(advSearchForm.searchCriteria.selectedIndex == 1 && advSearchForm.productName.value=="All"){
        AttributeAddRemAS.isDone("Please select a Character.");
        advSearchForm.productName.focus();
        return false;
    }else if(advSearchForm.searchCriteria.selectedIndex == 2 && advSearchForm.productBrandId.selectedIndex=="0"){
        AttributeAddRemAS.isDone("Please select a Brand.");
        advSearchForm.productBrandId.focus();
        return false;
    }else if(advSearchForm.searchCriteria.selectedIndex == 3 && advSearchForm.productCategoryId.selectedIndex=="0"){
        AttributeAddRemAS.isDone("Please select a Category.");
        advSearchForm.productCategoryId.focus();
        return false;
    }else if(advSearchForm.searchCriteria.selectedIndex == 4 && advSearchForm.minPrice.value=="" && advSearchForm.maxPrice.value==""){
        AttributeAddRemAS.isDone("Please enter value in Min & Max field.");
        return false;
    }else if(advSearchForm.searchCriteria.selectedIndex == 5 && MatchNumeric.isMatched(advSearchForm.minPrice.value) == false && MatchNumeric.isMatched(advSearchForm.maxPrice.value) == false){
        AttributeAddRemAS.isDone("Enter numeric value in Min & Max fields.");
        return false;
    }
    advSearchForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    advSearchForm.submit();
    return true;
}

function getProductDetail(actionpath,formname){
    var dealOfTheDayForm = document.forms[formname];

    dealOfTheDayForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    dealOfTheDayForm.submit();
    return true;
}

function validateCheckoutAddr(actionpath,formname){
    var checkoutAddrForm = document.forms[formname];

    checkoutAddrForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    checkoutAddrForm.submit();
    return true;
}

function paymentdelivery(actionpath,formname){
    var paymentDeliveryForm = document.forms[formname];

    paymentDeliveryForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    paymentDeliveryForm.submit();
    return true;
}

function payementCard(actionpath,formname){
    var paymentCardForm = document.forms[formname];

    paymentCardForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    paymentCardForm.submit();
    return true;
}

function payementBank(actionpath,formname){
    var paymentBankForm = document.forms[formname];

    paymentBankForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    paymentBankForm.submit();
    return true;
}

function signinGuest(actionpath,formname){
    var signInGuestForm = document.forms[formname];

    signInGuestForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    signInGuestForm.submit();
    return true;
}

function updateQty(actionpath,formname){
    var updateCartProductForm = document.forms[formname];

    updateCartProductForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    updateCartProductForm.submit();
    return true;
}

function changeOrderStatus(actionpath,selectOrderStatus, formname, orderId){

    var updateOrderStatusForm = document.forms[formname];
    var orderStatusId = selectOrderStatus.options[selectOrderStatus.selectedIndex].value;
    actionpath = actionpath + "&orderId="+orderId +"&orderStatusId="+orderStatusId;
    alert(actionpath);
    updateOrderStatusForm.action=actionpath+(actionpath.indexOf('?')!=-1?'&':'?') +"ddd="+Math.random();
    updateOrderStatusForm.submit();
    return true;
}

function validateUpload(formname){
    alert(formname);
    var uploadForm = document.forms[formname];
    
    var errmsgui = document.getElementById('errspanidui');
    var errdivui = document.getElementById('errdividui');
    
    var UploadImage = new Object();
    UploadImage.fileName=function(myFile){
        alert(myFile);
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null){
            alert ("Browser does not support HTTP Request");
            return;
        }
        var url="FileUpload.do?action=FileUploadAction";
        url=url+"&inputstring="+myFile;
        alert(url);
        xmlHttp.onreadystatechange=fileUpload;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }

    var AttributeAddRemUI = new Object();
    AttributeAddRemUI.isDone=function(msg){
        errdivui.setAttribute('class', 'errdivclass');
        errmsgui.setAttribute('class', 'errspanclass');
        errmsgui.innerHTML = msg;
        errdivui.appendChild(errmsgui);
    };

    if (uploadForm.myFile.value=="" || uploadForm.myFile.value.length<=0){
        AttributeAddRemUI.isDone("Please type in or browse to a file for uploading....");
        uploadForm.myFile.focus();
        return false;
    }else if(/.*\.(gif)|(jpeg)|(jpg)|(png)$/.test(uploadForm.myFile.value.toLowerCase())){
        alert(uploadForm.myFile);
        UploadImage.fileName(uploadForm.myFile);
        return true;
    }else{
        AttributeAddRemUI.isDone("Please Upload GIF/PNG or JPG/JPEG Images Files Only.");
        uploadForm.myFile['filepath'].focus();
        return false;
    }
    
}

function GetXmlHttpObject(){
    var xmlHttp=null;
    try{
        xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
    }catch (e){//Internet Explorer
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function fileUpload(){
    alert("Hello");
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        var data = xmlHttp.responseText;
        alert(data);
        if(data.length >0) {
            //document.getElementById('suggestCityCode').style.display="block";
            $('#suggestCityCode').show();
            //document.getElementById('suggestCityCodeValue').innerHTML=data;
            $('#suggestCityCodeValue').html(dataCityCode);
        }
    }
}